package com.sh.data.engine.repository.dao.datadev.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class OfflineDevApiWsEntity {
    private String protocol;

    private String address;

    private String addressUserNameKey;

    private String addressUserNameValue;

    private String addressPasswordKey;

    private String addressPasswordValue;

    private String service;

    private String port;

    private String operation;

    private String localClassPath;

    // 认证参数
    private ApiHttpAuthParam apiWsAuthParam;

    // 请求体
    private ApiHttpRequestBodyParam apiWsRequestBodyParam;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ApiHttpAuthParam {
        // 认证方式    noauth, basic, sign, token
        private String authType;

        // basic
        private String authUsername;

        private String authPassword;

        // sign
        private String accessKey;

        private String accessSecret;

        // token
        private String accessToken;

        private String advancedCacheKey;

        // 资源名字
        private String advancedFileName;
        // 资源路径
        private String advancedFilePath;

        private String advanceClassReference;

        private String advanceMethodName;

        // 变量有效期
        private Date expires;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ApiHttpRequestHeaderParam {
        // 请求头列表
        private List<Header> params;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        public static class Header {
            // 消息头名称
            private String name;
            // 具体值
            private String value;
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ApiHttpRequestBodyParam {

        private String contentType;
        // 请求体
        private String body;

        // url参数
        private List<FormParam> formParams;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        public static class FormParam {

            /**
             * 参数类型 0-输入参数 1-返回参数
             */
            private Integer paramType;

            /**
             * 参数名称
             */
            private String paramName;

            /**
             * 参数位置 query head body
             */
            private String paramPosition = "query";

            /**
             * 参数数据类型
             */
            private String paramDataType;

            /**
             * 参数值
             */
            private String paramValue;

            /**
             * 描述
             */
            private String paramDesc;

            /**
             * 返回参数取值表达式
             */
            private String paramExpression;

            /**
             * 参数属性 0-无(纯输入值) 1-pageNo 2-pageSize
             */
            private Integer paramAttribute = 0;
        }
    }
}
